﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Twi.COMMON.Core
{
   /**
    * Copyright: ©2015 踏影软件开发工作室【Tyingsoft、Twilight】版权所有
    * Author: feitianxinhong
    * Create Date:2015-04-08 
    * Description: TwiExpression 表达式辅助类，
    * 
    */
    public class TwiExpression
    {
        /// <summary>
        /// 根据表达式代码获取指定值
        /// </summary>
        /// <param name="expressionCode">表达式代码</param>
        /// <returns>表达式的值，或默认值null</returns>
        public static dynamic GetExpressionValueByCode(string expressionCode)
        {
            if (string.IsNullOrEmpty(expressionCode)) {
                return null;
            }
            expressionCode = expressionCode.ToUpper(); //全大写
            if (expressionCode == "IP")
            {
                return TwiNetHelper.GetIp();
            }
            else if (expressionCode == "DateTime".ToUpper())
            {
                return DateTime.Now;
            }
            else if (expressionCode == "DateTimeStr".ToUpper())
            {
                return TwiDateHelper.GetNowDateTime();
            }
            else {
                return null;
            }
        }
    }
}
